/**
 * 运营公司表品牌信息
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);

    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        switch(event){
            case 'event-to-add':
            {
                window.top.add_tab("运营公司表品牌信息 - 新增","/web/business/thrOperateCompanyBrand/toAdd");
                break;
            }
            case 'event-to-edit':
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else if(datas.length > 1) {
                    layer.alert('只能选中一行数据');
                } else {
                    window.top.add_tab("运营公司表品牌信息 - 编辑","/web/business/thrOperateCompanyBrand/toEdit?id="+ datas[0].id);
                }
                break;
            }
            case 'LAYTABLE_EXPORT_DATA'://导出
            {
                $scope.doExport('/api/inter/thrOperateCompanyBrand/export');
                break;
            }
            case 'event-to-del': {
                if (datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else {
                    var ids = '';
                    for(var i=0;i<datas.length;i++){
                        if(ids==''){
                            ids = datas[i].id;
                        }else {
                            ids = ids + ',' +datas[i].id;
                        }
                    }
                    layer.confirm('确定要删除吗？', { icon: 3 }, function() {
                        layer.msg('处理中', { icon: 16, shade: 0.01 });
                        $http.post('/api/inter/thrOperateCompanyBrand/toDelByList', {}, {params: {ids: ids}})
                            .success(function (res) {
                                layer.close();
                                location.reload();
                                layer.msg(res.msg);
                            })
                            .error(function(result){
                                layer.close();
                                layer.msg("操作失败，请稍后再试！", {icon: 2});
                            });


                    }, function() {
                    });
                }
                break;
            }


        };
    }
}

//表格双击
app.controller('dbClickCtrl', ['$scope', '$http', DbClickController]);
function DbClickController($scope, $http){
    $scope.doubleClick = function(data) {
        window.top.add_tab('运营公司表品牌信息 - 详情','/web/business/thrOperateCompanyBrand/toDetail?id=' + data.id);
    }
}




